<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page import="com.scalar.chiptrack.operations.dataentry.forms.SortDataEntryForm,
                com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.adaptor.SortLotBinData,
                 java.util.ArrayList,
                 com.scalar.chiptrack.commons.Constants" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/sortDataEntry.do"/>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type='text/css' rel='stylesheet'>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/sort_dataentry.js"></script>
</HEAD>
<BODY bgColor='#ffffff' leftMargin='0' topMargin='0' marginheight='0' marginwidth='0'>
<script language="javascript">
errMsg = '';

//Bhaskar added this function on 7 december 2003
function confirmUpdate()
{
	document.sortDataEntry.confirm.value='confirm';
	finalSave();
}


function finalSave()
{
    var form = document.sortDataEntry;
	var pa=document.getElementById("message");

    if(productSelected(form)==false)
    {
        return;
    }
    if(locationSelected(form)==false) // location Selected
    {
        return;
    }
    if(lotNoSelected(form)==false)
    {
        return;
    }

	if (! validateWaferQuantity () )
	{
		return;
	}

	if ( !validateLotId () )
	{
		return;
	}
	if ( !validateGrossDice () )
	{
		return;
	}
    if ( chkDate ( form.testDateIn.value , 'DateIn ' , 'Y' ) == false ){
          pa.innerHTML = errMsg;
          form.testDateIn.focus();
          return;
    }
    if( document.sortDataEntry.vendorLot.value.indexOf("'") != "-1" )
    {
        pa.innerHTML = "<li>Single quotation is not acceptable in Vendor Lot Number</li>";
        document.sortDataEntry.vendorLot.focus();
        return;
    }
	form.quantityOut.value = form.quantityOut.value.trim();
	if ( form.quantityOut.value.length > 0 )
	{
		if ( checkInteger( form.quantityOut.value , ' Die Out' , 'Y'  ) == false)
		{
			pa.innerHTML  = "<li> " + errMsg;
			form.quantityOut.focus();
			return;
		}
	}
    if( form.quantityOut.value != '' )
    {
        if( form.testDateOut.value == '' )
        {
            pa.innerHTML = "Please Enter the DateOut";
            form.testDateOut.focus();
			return;
        }
        /*if(form.quantityOut.value==0)
	    {
			pa.innerHTML = "Zero value is not permitted for Quantity Out, Please enter greater than Zero";
            form.quantityOut.focus();
			return;
	    }*/
    }
    form.grossDice.value = form.grossDice.value.trim();
	if( form.grossDice.value == '')
	{
		pa.innerHTML = "<li>Please Enter Gross Die</li>";
		form.grossDice.focus();
		return;
	}
	if( parseInt ( form.grossDice.value ) == 0 )
	{
		pa.innerHTML = "<li>Zero value is not permitted for Gross Die";
        form.grossDice.focus();
        return;
	}
	if ( form.grossDice.value.length > 0 )
	{
		if ( checkInteger ( form.grossDice.value, ' Gross Die ', 'Y' ) == false )
		{
			form.grossDice.focus();
			pa.innerHTML = "<li> "+errMsg;
			return;
		}
	}

	if(form.testDateOut.value!='')
	{
        if ( chkDate ( form.testDateOut.value , 'Date Out ' , 'Y' ) == false )
		{
              pa.innerHTML = errMsg;
              form.testDateOut.focus();
              return;
        }
		if(form.quantityOut.value=='')
		{
			pa.innerHTML = "Please Enter Sort Bin Data";
			return;
		}
    }

	if(form.testDateIn.value!='' && form.testDateOut.value!=''){
		if (!validateDateOut(formatDateAsMMDDYYYY(form.testDateIn.value),formatDateAsMMDDYYYY(form.testDateOut.value)))
		{
			pa.innerHTML = "Date Out cannot be less than Date In";
			form.testDateOut.focus();
			return;
		}
	}
	if( form.comments.value.trim().length > 1000 )
	{
		pa.innerHTML = "<li>Comments should not be greater than 1000 characters";
        form.comments.focus();
        return;
	}

	document.sortDataEntry.action="<%=chipTracContext%>/sortDataEntry.do?action=save";
    form.grossDice.disabled = false;
    form.yield.disabled = false;
    form.quantityOut.disabled = false;
	form.avgGoodDie.disabled = false;

	if ( !checkYieldDateOut() )
	{
		form.grossDice.focus();
		return;
	}
	document.sortDataEntry.submit();
}


function selectPartNumber()
{
    if(document.sortDataEntry.processStepId.value=='0')
    {
        document.sortDataEntry.action="<%=chipTracContext%>/sortDataEntry.do";
	    document.sortDataEntry.submit();
        return;
    }

	if(document.sortDataEntry.locationId!=null )
    {
	    document.sortDataEntry.locationId.value='0';
    }

	if(document.sortDataEntry.waferQuantity)
    {
        document.sortDataEntry.waferQuantity.value='';
        document.sortDataEntry.testDateIn.value='';
        document.sortDataEntry.testDateOut.value='';
        document.sortDataEntry.quantityOut.value='';
	}

	document.sortDataEntry.action="<%=chipTracContext%>/sortDataEntry.do?action=partnumber";
	document.sortDataEntry.submit();
}

function selectLotNumber()
{
    var form = document.sortDataEntry;

	if(document.sortDataEntry.lotId.value=='0')
    {
        document.sortDataEntry.action="<%=chipTracContext%>/sortDataEntry.do?action=location";
	    document.sortDataEntry.submit();
    	return ;
    }
    if(productSelected(form)==false)
    {
        return;
    }
    if(locationSelected(form)==false)
    {
        return;
    }

	document.sortDataEntry.action="<%=chipTracContext%>/sortDataEntry.do?action=lotnumber";
	document.sortDataEntry.submit();
}

function selectLocation()
{
    var form = document.sortDataEntry;

	if(document.sortDataEntry.locationId.value=='0')
    {
        document.sortDataEntry.action="<%=chipTracContext%>/sortDataEntry.do?action=partnumber";
	    document.sortDataEntry.submit();
	    return ;
    }
    if(productSelected(form)==false)
    {
        return;
    }

	document.sortDataEntry.action="<%=chipTracContext%>/sortDataEntry.do?action=location";
	document.sortDataEntry.submit();
}


// added by hareesh on 6th December 2003
// -- START --
	function binSortDataEntry()
	{
		errors = "";
		var pa=document.getElementById("message");
		pa.innerHTML = errors;
		var form = document.sortDataEntry;
		form.waferQuantity.value = form.waferQuantity.value.trim();
		form.goodBinsCount.value = form.goodBinsCount.value.trim();
		form.grossDice.value	 = form.grossDice.value.trim();
		waferQty  =  form.waferQuantity.value;
		goodBinsCount = form.goodBinsCount.value;
		grossDice = form.grossDice.value;
		if ( checkInteger( waferQty.trim() , ' Wafer Quantity In' , 'Y'  ) == false )
		{
			pa.innerHTML = "<li> "+ errMsg;
			errors = errMsg;
			form.waferQuantity.focus();
			return;
        }
		else
		{
            if( form.waferId == null)
			{
				addNewBins( waferQty, goodBinsCount );
            } 
			else if ( (waferQty > 1) && ( form.waferId.length == null ) )
			{
				addNewBins( waferQty - 1, goodBinsCount );
            } 
			else if ( form.waferId.length < waferQty )
			{
				addNewBins( waferQty - form.waferId.length, goodBinsCount );
            }
        }
		if ( checkInteger( grossDice , ' Gross Die ' , 'Y'  ) == false )
		{
			pa.innerHTML = "<li> "+errMsg;
			errors = errMsg;
			form.grossDice.focus();
			return;
        }

		if ( parseInt ( grossDice ) <= 0 )
		{
			errors = "Gross Die should be greater than zero";
			pa.innerHTML = "<li> "+errors;
			form.grossDice.focus();
			return;
        }
		if( errors == "" )
		{
            form.grossDice.disabled = true;
            form.yield.disabled = true;
            form.quantityOut.disabled = true;
            newWindow = window.open ('<%=chipTracContext%>/jsp/operations/bin_sort_data_entry.jsp?waferQty='+waferQty+'&goodBinsCount='+goodBinsCount,'BinSetupPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=450,resizable=yes');
            newWindow.focus();
        }
    }

    function updateBinId ( binCount, waferId, binRejected, binYield ){
        var form = document.sortDataEntry;
        if(form.waferId.length != null){
            form.waferId[binCount].value = waferId;
            form.binRejected[binCount].value = binRejected;
            form.binYield[binCount].value = binYield;
        }else{
            form.waferId.value = waferId;
            form.binRejected.value = binRejected;
            form.binYield.value = binYield;
        }
    }

    function updateBinValues( binCount, binIndex, binValue ){
        var form = document.sortDataEntry;
        if(form.waferId.length != null){
            eval( "form.bin_"+binIndex )[ binCount ].value =  binValue;
        }else{
            eval( "form.bin_"+binIndex ).value = binValue;
        }
    }

    function addNewBins(count, countOfBins){
        var binObject =  "<input type='hidden' name='waferId' value=''>";
        var binObject =  binObject+"<input type='hidden' name='binYield' value=''>";
        for(i=0; i <= countOfBins; i++){
            binObject = binObject +  "<input type='hidden' name='bin_" + i + "' value=''> ";
        }
        binObject = binObject+"<input type='hidden' name='binRejected' value=''>";
        var newBinObject = document.getElementById("newBins");
        //alert(binObject);
        for(i = 0; i < count; i++){
            newBinObject.insertAdjacentHTML('BeforeEnd',binObject);
        }
    }


//Bhaskar added this date picker functionality on 12 Feb 2004
	var dateElement = "";
	function openCalendar(dateValue)
	{
		dateElement = dateValue;
		newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
		newWindow.moveTo(550,180);
		newWindow.focus();
	}

	function assignDate(passedValue)
	{
		dateElement.value=passedValue;
		window.focus();
	}

function checkLength(element, size)
{
    if(	element.value.length >= size )
	{
		event.returnValue = false;
	}
}

function showLotInformation()
{
    var processStepId = document.sortDataEntry.processStepId.value;
    var lotNo         = document.sortDataEntry.lotNo.value;
    var locationId    = document.sortDataEntry.locationId.value;
    newWindow = window.open ('<%=chipTracContext%>/sortDataEntry.do?action=allLotInfo&LotNo='+lotNo+'&ProcessStepId='+processStepId+'&LocationId='+locationId,'optionsPopup1','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=450,resizable=no');
    newWindow.focus();
}

function pickLotNumber()
{
    var form = document.sortDataEntry;
    var processStepId = form.processStepId.value;
    var locationId    = document.sortDataEntry.locationId.value;
    newWindow = window.open ('<%=chipTracContext%>/sortReleaseLots.do?processStepId=' + processStepId+'&locationId='+locationId,'sortReleaseLotsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=400,resizable=yes');
    newWindow.focus();
}
function assignLotNumber ( lotNumber, noofwafers, waferId )
{

    var form = document.sortDataEntry;
    var tempWafers = waferId.split(';');
    goodBinsCount = form.goodBinsCount.value;

    if( noofwafers > 1 )
    {
        Quicksort( tempWafers, 0, noofwafers- 1 );
    }
    if( form.waferId == null )
    {
        addNewBins( noofwafers, goodBinsCount );
    }
    else if ( ( noofwafers > 1 ) && ( form.waferId.length == null ) )
    {
        addNewBins( noofwafers - 1, goodBinsCount );
    }
    else if ( form.waferId.length < noofwafers )
    {
        addNewBins( noofwafers - form.waferId.length, goodBinsCount );
    }
    for( var i=0; i< noofwafers; i++)
    {
        if( noofwafers > 0 )
        {
            if( noofwafers > 1 )
            {
                for( count = 0; count < noofwafers ; count++ )
                {
                    updateBinId( count, tempWafers[count], "", 0.00 );
                }
            }
            else
            {
                updateBinId( 0 , tempWafers[0],"", 0.00);
            }
        }
    }
    form.lotNo.value = lotNumber;
    form.waferQuantity.value = noofwafers;
}


function Quicksort(vec, loBound, hiBound)
{

    var pivot, loSwap, hiSwap, temp;

    // Two items to sort
    if (hiBound - loBound == 1)
    {
        if (eval(vec[loBound]) > eval(vec[hiBound]))
        {
            temp = vec[loBound];
            vec[loBound] = vec[hiBound];
            vec[hiBound] = temp;
        }
        return;
    }

    // Three or more items to sort
    pivot = eval(vec[parseInt((loBound + hiBound) / 2)]);
    vec[parseInt((loBound + hiBound) / 2)] = vec[loBound];
    vec[loBound] = pivot;
    loSwap = loBound + 1;
    hiSwap = hiBound;

    do {
        // Find the right loSwap
        while (loSwap <= hiSwap && eval(vec[loSwap]) <= pivot)
            loSwap++;

        // Find the right hiSwap
        while (eval(vec[hiSwap]) > pivot)
            hiSwap--;

        // Swap values if loSwap is less than hiSwap
        if (loSwap < hiSwap)
        {
            temp = vec[loSwap];
            vec[loSwap] = vec[hiSwap];
            vec[hiSwap] = temp;
        }
    } while (loSwap < hiSwap);

    vec[loBound] = vec[hiSwap];
    vec[hiSwap] = pivot;


    // Recursively call function...  the beauty of quicksort

    // 2 or more items in first section
    if (loBound < hiSwap - 1)
        Quicksort(vec, loBound, hiSwap - 1);


    // 2 or more items in second section
    if (hiSwap + 1 < hiBound)
        Quicksort(vec, hiSwap + 1, hiBound);
}


// -- EnD --

</script>

<!-- Top Header Start-->

<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
<!-- Side Navigation start -->
<%@ include file="/jsp/operations/dataentryMenu.jsp" %>
<!-- end of the side navigations -->
<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->
<html:form name="sortDataEntry"  type="com.scalar.chiptrack.operations.dataentry.forms.SortDataEntryForm" action="/sortDataEntry">

<!--center><span class="NArialW">Sort Data Entry</span></center>
<p>&nbsp; <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
<font class="NArialL">

</p-->

<table border="0" width="90%" align="center">
<tr><td class="NArialW" colspan="5" align="center">Sort Data Entry</td></tr>
<tr><td colspan=5>&nbsp;</td></tr>
<!--p>&nbsp; <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
<font class="NArialL"></p-->
<tr><td colspan=5 class='NArialL'><B><FONT id="message" styleClass="NArialL" color='FF0000'></FONT></b></td></tr>
<tr><td colspan=5>
  <chiptrack:info styleClass="NArialL" />
  <chiptrack:errors styleClass="NArialL" />
  <chiptrack:messages type="info" styleClass="NArialL" />
</td></tr>
<logic:equal name="showMessage" value="TRUE">
    <tr><td colspan=5 align='left'><font class='NArialS'color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></td></tr>
</logic:equal>
<tr><td colspan=5>
<logic:equal name="showError" value="TRUE">
<font class="NArialL"><a styleClass="leftsection" href="javascript:showLotInformation()"
                        onmouseover="window.status='Click to show All Lot info';return true" onmouseout="window.status='';return true">Click here</a>
                        &nbsp;to view Lot History</font></td></tr>

<tr><td>
<font face="Verdana" size="-3" color="#ff0000"><b>This lot already exists for given Part Number and Location. Do u wish to overwrite</b></font>
    <a href="javascript:confirmUpdate();" onmouseover="window.status='Click to Confirm Updation';return true" onmouseout="window.status='';return true" title="Click here to Confirm Updation"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/confirm.gif"
	width="75" height="17"></a>
    &nbsp;&nbsp;&nbsp;
    <a href="<%=chipTracContext%>/sortDataEntry.do">
	<img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width="53" height="17" onmouseover="window.status='Click to Cancel Overwriting';return true" onmouseout="window.status='';return true" title="Click here to Cancel Overwriting"></a>
</logic:equal>
</td></tr>
<tr><td>
<table border="0" width="90%" align=left>
<tr><td>
<table border="0" width="100%">
  <tr>
    <td width="25%" class="NArialL">Product Name:</td>
    <td width="25%" class="NArialL">
		<html:select property="processStepId"  name="sortdataentryform"
		styleClass="txfield" onchange="selectPartNumber()" >
		<html:option value="0">Select Part  Number</html:option>
		<html:options collection="partNumberSelectList" property="value" labelProperty="label"/>
		</html:select>
    </td>

   <%
       String action = (String)request.getAttribute("action");
       if(action==null)
       action="";

       if ( action.equals ( "location" ) || action.equals ( "save" ) || action.equals ( "lotnumber" ) || action.equals ( "partnumber" ) ) {
	   %>
    <td width="20%" class="NArialL">Location:</td>
    <td width="20%" align=left class="NArialL">
		<html:select property="locationId"  name="sortdataentryform" styleClass="txfield" onchange="selectLocation()"  >
		<html:option value="0">Select Location</html:option>
		<html:options collection="locationSelectList" property="value" labelProperty="label"/>
		</html:select>
	</td> <%} else { %>
    <td width="20%">&nbsp;</td>
    <td width="25%">&nbsp;</td>
<% } %>
  </tr>
  <tr>

<%if ( action.equals ( "location" ) || action.equals ( "lotnumber" ) || action.equals ( "save" ) ) {
	   %>
    <td width="20%" class="NArialL">Lot Number:</td>
    <td width="25%" class="NArialL">
		<html:select property="lotId"  name="sortdataentryform" styleClass="txfield" onchange="selectLotNumber()"  >
		<html:option value="0">Select Lot  Number</html:option>
		<html:option value="-1">--New Lot Number--</html:option>
		<html:options collection="lotNumbers" property="value" labelProperty="label"/>
		</html:select>
    </td><%}%>

	<!--  added by ravikanth for po number --> 
	<%if(action.equals("save")  || action.equals("lotnumber") ){
	   %>
		<td width="20%" class="NArialL">PO Number :</td>
		<td width="20%" align=left class="NArialL">
			<html:text property="poNumber" size = "16" maxlength="40" styleClass="txfield" name="sortdataentryform" />
		</td>
	   <% } %>

	<tr><td colspan=4 width="7%">&nbsp;</td></tr>
	<%if(action.equals("save")  || action.equals("lotnumber") ){
	   %>
            <logic:equal name="sortdataentryform" property="lotId" value="-1">
                <tr>
                    <td width="20%" colspan="2" ><font class="NArialL"></td>
                    <td width="50%" colspan="2" class="NArialL"><A href="javascript:pickLotNumber()">Pick Lot Number</A></td>
                </tr>
            </logic:equal>

            <tr>
             <logic:equal name="sortdataentryform" property="lotId" value="-1">
             <td width="20%"><font class="NArialL">New Lot Number: <font color="red">*</font></font></td>
             <td width="20%"><font class="NArialL">
             <html:text  property="lotNo" size="25" styleClass="txfield" maxlength="50" name="sortdataentryform" />
             </font></td>
             <td width="25%" class="NArialL">AVG.GOOD Die/Wafer:</td>
            <td width="25%">
            <html:text property="avgGoodDie" name="sortdataentryform" size="16" styleClass="valuetxfield" maxlength="7" disabled='true' />
            </td>
            </logic:equal>
            <logic:notEqual name="sortdataentryform" property="lotId" value="-1">
                <html:hidden property="avgGoodDie" name="sortdataentryform" />
                <td width="20%"><font class="NArialL">&nbsp;
                <html:hidden  property="lotNo" name="sortdataentryform" />
                </font></td>
				<td width="20%" class="NArialL">&nbsp;</td>
             <td width="20%" class="NArialL">&nbsp;</td>
             <td width="20%" class="NArialL">&nbsp;</td>

            </logic:notEqual>
			</tr>
  <tr>
    <td width="20%"><font class="NArialL">Wafer Quantity In: <font color="red">*</font></font></td>
    <td width="20%">
	<html:text property="waferQuantity" name="sortdataentryform" size="16" styleClass="valuetxfield" maxlength="3" />
	<!--This hidden die size is added to avoid the problem of altering the wafer quantity or die size at
	the time of saving the sort data. Bhaskar on 14 Mar 2004-->
	<input type="hidden" name="hiddenWaferQuantity">
	</td>
     <td width="20%" class="NArialL">Die Out:</td>
    <td width="25%">
	<% Object tempBinObj = request.getAttribute("sortLotBinData"); %>
	<!--% SortDataEntryForm sdeForm1 = (SortDataEntryForm) request.getAttribute("sortdataentryform"); %-->
	<!--% if ( ( sdeForm1.getYield().trim().length() == 0 ) || ( ( sdeForm1.getYield().trim().length() > 0 )&& (Float.parseFloat ( sdeForm1.getYield() ) == 0.0f ) ) ){ %-->
	<% if ( tempBinObj != null ) { %>
	<html:text property="quantityOut" name="sortdataentryform" size="16" styleClass="valuetxfield" maxlength="7" disabled="true" /></td>
	<% } else { %>
	<html:text property="quantityOut" name="sortdataentryform" size="16" styleClass="valuetxfield" maxlength="7" disabled="true"/>
	<% } %>
	</td>
  </tr>
<tr>

    <td width="20%" class="NArialL">Date In: <font color="red">*</font></td>

    <td width="20%">
	<html:text property="testDateIn" name="sortdataentryform" size="16" styleClass="txfield" maxlength="10" />
	<a href="javascript:openCalendar(document.sortDataEntry.testDateIn)">
	<img onMouseOver="window.status='Click to select date';return true" onmouseout="window.status='';return true" border="0" align='center'
	src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
    </td>
    <td width="20%" class="NArialL">Date Out:</td>
    <td width="25%" class="NArialL">
    <html:text property="testDateOut" name="sortdataentryform" size="16" styleClass="txfield" maxlength="10" />
	<a href="javascript:openCalendar(document.sortDataEntry.testDateOut)">
	<img onMouseOver="window.status='Click to select date';return true"  onmouseout="window.status='';return true" border="0" align='center'
	src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>

    </td>
</tr>

<tr>
    <td width="25%" class="NArialL">Gross Die:<font color = "red">*</font></td>
    <td width="25%">
	<html:text property="grossDice" name="sortdataentryform" size="16" styleClass="valuetxfield" maxlength="7" disabled="true"/>
    </td>
    <td width="25%" class="NArialL">Ship Yield:</td>
    <td width="25%" class="NArialL">
    <html:text property="yield" name="sortdataentryform" size="16" styleClass="valuetxfield" disabled="true" />
    </td>
</tr>

<tr>
    <td width="25%" class="NArialL">DateCode:<font color = "red">*</font></td>
    <td width="25%">
	<html:text property="dateCode" name="sortdataentryform" size="16" styleClass="valuetxfield" maxlength="50" />
    </td>
    <td width="25%" class="NArialL">Lot Category:<font color = "red">*</font></td>
    <td width="25%" class="NArialL">
        <html:select property="lotCategory" styleClass="txfield" name = "sortdataentryform">
        <html:option value="">Select Lot Category</html:option>
        <html:options collection="lotCategoryList" property="value" labelProperty="label"/>
        </html:select>
    </td>
</tr>
<html:hidden name="sortdataentryform" property="fabGrossDie"/>

<tr>
    <html:hidden property="goodBinsCount" name="sortdataentryform" />
    <html:hidden property="rejectedBinsCount" name="sortdataentryform" />
    <td width="25%" class="NArialL">Vendor Lot Number:</td>
    <td width="25%">
    <html:text property="vendorLot" name="sortdataentryform" size="16" styleClass="valuetxfield" maxlength="50" />
    </td>
    <td width="10%">
    <%  Object tempObject = request.getAttribute("sortLotBinData");
        Object tempObject1 = request.getAttribute("sortdataentryform");
        int goodBins = 0;
        int rejectedBins =1;
        if(tempObject1 != null){
             SortDataEntryForm sortDataEntryForm = (SortDataEntryForm) tempObject1;

            try{
             goodBins = Integer.parseInt( sortDataEntryForm.getGoodBinsCount()) ;
            }catch(Exception ex){ goodBins  = 0; }
            try{
             sortDataEntryForm.getRejectedBinsCount();
            }catch(Exception ex){ rejectedBins = 1; }
            //System.out.println(goodBins +"........." );
            //System.out.println(rejectedBins+".... ..."  );
        }
        if(tempObject != null){
            SortLotBinData sortLotBinData = (SortLotBinData)tempObject;
            java.util.ArrayList waferList = sortLotBinData.getWaferIdList();
            java.util.ArrayList binList = sortLotBinData.getBinList();
            if( waferList != null){
                int waferSize = waferList.size();
                for(int count = 0; count < waferSize; count++ ){
                    tempObject = waferList.get ( count );
                    java.util.ArrayList binListByWafer = ( java.util.ArrayList ) binList.get(count);
                    String waferId = "";
                    String binRejected = "";
                    String binYield = "";
                    String bin[] = new String [goodBins+1];

                    if(tempObject != null){
                          java.util.ArrayList temp_it = (java.util.ArrayList)tempObject;
                          waferId =  temp_it.get ( 0 ) != null ? ( ( String ) temp_it.get ( 0 ) ).trim() : ""; // waferId
                          //System.out.println( "........." + waferId );
                           binYield =  temp_it.get ( 3 ) != null ? ( ( String ) temp_it.get ( 3 ) ).trim() : ""; // yield
                          //System.out.println( "........." + binYield );
                          for( int binCount = 0; binCount < goodBins; binCount++)
                          {
                                bin[binCount] = binListByWafer.get ( binCount) != null ? ( ( String ) binListByWafer.get ( binCount) ).trim() : ""; // bin
                                binRejected =  temp_it.get ( 5 ) != null ? ( ( String ) temp_it.get ( 5 ) ).trim() : ""; // bin rejected
                          }
                     %>
                           <input type='hidden' name='waferId' value='<%= waferId  %>'>
                           <input type='hidden' name='binRejected' value='<%= binRejected  %>'>
                           <input type='hidden' name='binYield' value='<%= binYield  %>'>
                      <%
                           for( int binCount = 0; binCount < goodBins+1; binCount++) {
                       %>
                            <input type='hidden' name='bin_<%=binCount%>'  value='<%= bin[ binCount ] %>'  >
                       <%
                           }
                      }
                }
            }
        }
    %>
    <FONT id="newBins" styleClass="NArialL" color='FF0000'></FONT></td>
    <td width="25%" align="left"><font class="NArialL">
    <a href="javascript:binSortDataEntry();" onMouseOver="window.status='Click here to Entry Sort Bin Data';return true" onMouseOut="window.status='';return true">
    Sort Bin Data Entry</a></font></td>
</tr>
<%--<tr>
		<td width="20%"><font class="NArialL">Vendor Lot Number</font> </td>
		<td width="25%"><html:text property="vendorLot" name="sortdataentryform" size="16" styleClass="valuetxfield" maxlength="50" />
	     </td>
         <td width="20%">&nbsp;</td>
		<td width="20%">&nbsp;
		</td>
	</tr>--%>
    <TR>
		<TD class='NArialL'>Comments : </TD>
        <TD colspan = 3>
		<html:textarea property="comments" name="sortdataentryform"  styleClass="txfield" rows="4" cols="80" onkeypress="javascript:checkLength(this, 1000)" />
		</TD>
	</TR>


<tr><td colspan=4 width="7%">&nbsp;</td></tr>
<tr>
  <td align=center colspan=4>
  <input type="hidden" name="confirm" value="">
  <chiptrack:restrictedLink functionality='<%=Functionality.DATA_ENTRY%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:finalSave();' onmouseover="window.status='Click to Save Sort Data';return true" onmouseout="window.status='';return true">
        <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" title="Click here to Save Sort Data"/>
  </chiptrack:restrictedLink>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <a href="<%=chipTracContext%>/sortDataEntry.do"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width="53" height="17"onmouseover="window.status='Click to Cancel Changes';return true" onmouseout="window.status='';return true" title="Click here to Cancel Changes"></a>
</td></tr>

<%}%>
</table>

<!--<p align="center"> <a href="javascript:wafer()"><img align ="center" border="0" src="<%=chipTracContext%>/jsp/includes/images/next.gif" width="53" height="17"></a></p>-->

</td></tr>
<tr><td>

</td></tr>

</table>
</td></tr>

</table>
</html:form>
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>